//
//  InputCheckTool.swift
//  DemoNavBar
//
//  Created by YangHuan on 2019/12/16.
//  Copyright © 2019 YangHuan. All rights reserved.
//

import Foundation

public final class InputCheckTool {
    
    /// 校验密码
    func checkPassword(_ input: String) -> Bool{
        
        
        return input.count >= 6 && input.count <= 16
    }
    
    /// 校验手机号
    func checkPhone(_ input: String) -> Bool{
        
        return input.count == 11 && isTelNumber(num: input)
    }
    
    func isTelNumber(num:String) -> Bool {
        let mobile = "^1[3-9]{1}[0-9]{9}" //0?(13|14|15|17|18|19)[0-9]{9}
        let regextestmobile = NSPredicate(format: "SELF MATCHES %@",mobile)
        return regextestmobile.evaluate(with: num) == true
    }
    
    // 验证是否包含特殊字符
    static func isContainSpecialSymbols(_ input: String) -> Bool {
        let str = "^[A-Za-z0-9\\u4e00-\\u9fa5]+$"
        let preducate = NSPredicate.init(format: "SELF MATCHES %@", str)
        if !preducate.evaluate(with: input) {
            return true
        }
        return false
    }
}
